<template>
    <div>
     <table>
        <tbody>
            <tr>
                <td>房间类型</td>
                <td><input type="text" v-model="list.houseName"></td>
            </tr>
            <tr>
                <td>房间价格</td>
                <td><input type="text" v-model="list.price"></td>
            </tr>
            <tr>
                <td>是否有押金</td>
                <td>
                    <input type="radio" :value="true" v-model="list.isDeposit">需要
                    <input type="radio" :value="false" v-model="list.isDeposit">不需要
                     <input type="text" v-model="list.deposit":disabled="list.isDeposit==false">
                </td>
            </tr>
           
            <tr>
                <td>面积</td>
                <td><input type="text" v-model="list.area"></td>
            </tr>
            <tr>
                <td>人数</td>
                <td><input type="text" v-model="list.count"></td>
            </tr>
            <tr>
                <td>加床方式</td>
                <td><input type="text" v-model="list.extrabed"></td>
            </tr>
            <tr>
                <td>房间图片</td>
                <td><input type="text" v-model="list.houseImg"></td>
            </tr>
            <tr>
                <td>状态</td>
                <td> <input type="radio" :value="true" v-model="list.isDeposit">true
                    <input type="radio" :value="false" v-model="list.isDeposit">false
                </td>
            </tr>
            <tr>
                <td>房间类型</td>
                <td>
                <select v-model="list.tid">
                    <option value="">请选择</option>
                    <option value="1">大床房</option>
                    <option value="2">标准房</option>
                </select>
            </td>
            </tr>
            <tr>
                <td colspan="2"><input type="button" value="保存" @click="Update"></td>
                <td></td>
            </tr>
        </tbody>
     </table>
    </div>
</template>

<script setup lang="ts">
import {ref,onMounted}from "vue";
import axios from "axios";
import { useRouter,useRoute } from "vue-router";
const router=useRouter();
const route=useRoute();
const list=ref({
    "houseId": 0,
  "houseName": "string",
  "price": 0,
  "isDeposit": true,
  "deposit": 0,
  "area": 0,
  "count": 0,
  "extrabed": 0,
  "houseImg": "string",
  "state": true,
  "tid": 0
})
onMounted(()=>{
    Fantian(); 
})
const Fantian=()=>{
   var houseId=route.query.hid;
   axios.get("https://localhost:7242/api/House/GetId",{params:{hid:houseId}}).then(res=>{
      list.value=res.data;
   })
}




const Update=()=>{
    axios.put("https://localhost:7242/api/House/Update",list.value).then(res=>{
        if(res.data>0){
            alert('修改成功');
            router.push({
                path:"/"
            });
        }else{
            alert('添加失败');
        }
        
    })
}
</script>

<style scoped>

</style>